﻿using System;
using System.Collections.Generic;

using System.Text;
using RebEngine.Interfaces;
using Microsoft.Xna.Framework.Media;
using RebEngine.Managers;

namespace RebEngine.Sound
{
    public class RebMusic: IRebMusic
    {
        private string sFileName;
        public string FileName
        {
            get { return sFileName; }
            set { sFileName = value; }
        }

        private Song sBaseSong;
        public Song BaseSong
        {
            get { return sBaseSong; }
        }

        private bool bReadyToPlay = false;
        /// <summary>
        /// Used to check whether song is loaded and ready to be played.
        /// </summary>
        public bool ReadyToPlay
        {
            get { return bReadyToPlay; }
        }

        public RebMusic()
        { }

        public RebMusic(string filename)
        {
            sFileName = filename;
        }

        public void LoadContent()
        {
            if (!String.IsNullOrEmpty(sFileName))
            {
                try
                {
                    sBaseSong = EngineManager.ContentManager.Load<Song>("Content/Music/"+ sFileName);
                    bReadyToPlay = true;
                }
                catch
                {
                    //_baseSong = EngineManager.ContentManager.Load<Song>("Content/Music/Firefly");
                    //_readyToPlay = true;
                }
            }
        }

        public void UnloadContent()
        {
            sBaseSong.Dispose();
        }

    }
}
